package com.ewing.extranal.im.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.axis.utils.StringUtils;

import com.ewing.extranal.im.dto.ImUserInfo;

/**
 * 类/接口注释
 * 
 * @author tansonlam
 * @createDate 2016年5月4日
 * 
 */
public class ImUserImpl implements ImUser {
    private final static Map<Long, ImUserInfo> userTable = new HashMap<>();

    @Override
    public Boolean addImUser(Long imUserId, String name, String iconUrl) {
        if (userTable.get(imUserId) != null)
            return false;
        ImUserInfo imUserInfo = new ImUserInfo();
        imUserInfo.setImUserId(imUserId);
        imUserInfo.setSex(0);
        imUserInfo.setName(name);
        imUserInfo.setIconUrl(StringUtils.isEmpty(iconUrl) ? "img/person.jpg" : iconUrl);
        userTable.put(imUserId, imUserInfo);
        return true;
    }

    @Override
    public ImUserInfo getUserInfo(Long imUserId) {
        return userTable.get(imUserId);
    }

}
